import common_tools
from pydirectinput_km_handler import PyDirectinputKmHandler

key_mouse_handler = PyDirectinputKmHandler()


def do_open_zhi_bo_jian():
    zhi_bo_jian_icon = common_tools.read_gray_img('images/zhi_bo_jian.png')
    zhi_bo_jian_title = common_tools.read_gray_img('images/zhi_bo_jian_title.png')
    screen_img, screen_img_gray = common_tools.take_full_screenshot()
    zhi_bo_jian_title_xy = common_tools.find_img_xy(screen_img_gray, zhi_bo_jian_title)
    if len(zhi_bo_jian_title_xy) > 0:
        return True
    zhi_bo_jian_icon_xy = common_tools.find_img_xy(screen_img_gray, zhi_bo_jian_icon)
    if len(zhi_bo_jian_icon_xy) > 0:
        x, y = zhi_bo_jian_icon_xy
        key_mouse_handler.move_mouse_click(x, y)
    return False

def do_click_emoji():
    pass

if __name__ == '__main__':
    common_tools.execute_until_true(do_open_zhi_bo_jian, 5, 0.3)